#!/usr/bin/python
import os, sys, string

class XXFileDuplicate:
	def __init__(self):
		pass
	
	def printHelp(self, cmd):
		print 'Please use the following cmd:'
		print '    ' + cmd + ' file oldStr newStr'
		print 'e.g.'
		print '    ' + cmd + ' /home/fkong/build.xml 12345 54321' 

	def check(self, file):
		inputfile = file
		outputfile = file + '.0123456789'
		input = open(inputfile, 'r')
		#output = open(outputfile, 'w')
		lastline = ""
		lineNum = 0
		for line in input.xreadlines() :
			lineNum += 1
			if line == "" or lineNum == 1 :
				continue
			if line == lastline :
				dup = str(lineNum - 1) + ' : ' + line + str(lineNum) + ' : ' + line
				print dup
				#print str(lineNum - 1) + ' : ' + line
				#print str(lineNum) + ' : ' + line
			else:
				lastline = line
		input.close()
		#output.close()

if len(sys.argv) != 2:
	t = XXFileDuplicate()
	t.printHelp(sys.argv[0])
else:
	t = XXFileDuplicate()
	file = sys.argv[1]
	t.check(file)
